package service;

import utils.Constant;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.concurrent.ConcurrentHashMap;

@WebListener
public class LoginSessionListener implements ServletContextListener { ;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ConcurrentHashMap<String, HttpSession> map = new ConcurrentHashMap<>();
        // 放到 application
        ServletContext servletContext = sce.getServletContext();
        servletContext.setAttribute(Constant.ONLINE_USER,map);
    }

}
